using System.Web.UI;
using Microsoft.SharePoint.WebPartPages;
using System.IO;
using Microsoft.SharePoint.WebControls;
using System.Web;
using System.Diagnostics;

namespace Macaw.Wss3.DateFormatModifySolution
{
    public class DateTimeControlAdapter : System.Web.UI.Adapters.ControlAdapter
    {
        public DateTimeControl TypedControl
        {
            get
            {
                return this.Control as DateTimeControl;
            }
        }

        protected override void CreateChildControls()
        {
            Trace.WriteLine(string.Format("{0}: CreateChildControls()" , this.GetType().FullName));
            if (TypedControl == null)
            {
                base.CreateChildControls();
                return;
            }
            Trace.WriteLine(string.Format("{0}: Current Culture \"{1}\"", this.GetType().FullName, TypedControl.LocaleId));
            if (TypedControl.LocaleId == 2067 || TypedControl.LocaleId == 2060)
            {                
                TypedControl.LocaleId = 1043;
                Trace.WriteLine(string.Format("{0}: Current Culture modified to \"{1}\"", this.GetType().FullName, TypedControl.LocaleId));
            }

            
            base.CreateChildControls();
        }
    }
}